package com.example.egweibo1.base.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class JsonResult {
    private int code;
    private String message;
    private Object data;

    public JsonResult(Status status, Object data) {
        this.code = status.getCode();
        this.message = status.getMsg();
        this.data = data;
    }

    public JsonResult(Status status) {
        this(status, null);
    }

    public static JsonResult ok() {
        return JsonResult.ok(null);
    }

    public static JsonResult ok(Object data) {
        return new JsonResult(Status.SUCCESS, data);
    }
}
